﻿namespace PrismEx.SampleApp
{
    using System;
    using System.Globalization;
    using System.Windows.Data;
    using System.Windows.Markup;

    public class ToLowerCaseConverter : MarkupExtension, IValueConverter
    {
        private static ToLowerCaseConverter instance;

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var s = value as string;

            return s != null ? s.ToLower() : null;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return instance ?? (instance = new ToLowerCaseConverter());
        }
    }
}